package cn.dkk.create_design.prototype.shallow_clone_prototype;

import cn.dkk.create_design.factory.pojo.parent.Coffee;

/**
 * 通过Object的clone方法来实现浅克隆的原型模式
 *
 * 注意,clone方法并不是通过new来创建新对象的
 */
public class ShallowClonePrototype implements Cloneable{

    private Coffee coffee;

    public Coffee getCoffee() {
        return coffee;
    }

    public void setCoffee(Coffee coffee) {
        this.coffee = coffee;
    }

    public ShallowClonePrototype(Coffee coffee) {
        this.coffee = coffee;
    }

    @Override
    protected ShallowClonePrototype clone() throws CloneNotSupportedException {
        return (ShallowClonePrototype) super.clone();
    }
}
